package com.ruicar.afs.cloud.account.common.job;


import com.ruicar.afs.cloud.account.common.run.VoucherService;
import com.ruicar.afs.cloud.account.common.send.VoucherItemSendService;
import com.ruicar.afs.cloud.account.common.send.VoucherSendService;
import com.ruicar.afs.cloud.common.job.core.biz.model.ReturnT;
import com.ruicar.afs.cloud.common.job.core.handler.annotation.AfsJob;
import com.ruicar.afs.cloud.common.job.core.handler.annotation.AfsJobHandler;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@AfsJob
@AllArgsConstructor
@Slf4j
@Component
public class VoucherJob {
    private final VoucherItemSendService voucherItemSendService;
    private final VoucherService voucherService;
    private final VoucherSendService voucherSendService;

    /**
     * @Description 凭证信息推送
     */
    @AfsJobHandler(value = "voucherInfoSend")
    public ReturnT<String> timingTriggerVoucherInfoSend(String params) {
        try{
            voucherSendService.voucherInfoSend();
        } catch (Throwable e) {
            log.error("凭证发送异常", e);
        }
        return ReturnT.SUCCESS;
    }
    /**
     * @Description 凭证底表生成
     */
    @AfsJobHandler(value = "generatingBaseVoucher")
    public ReturnT<String> timingTriggerGeneratingBaseVoucher(String params) {
         voucherService.timingTriggerGeneratingBaseVoucher();
        return ReturnT.SUCCESS;
    }

    /**
     * @Description 合同激活辅助帐发送
     */
    @AfsJobHandler(value = "voucherItemSend")
    public ReturnT<String> timingTriggerVoucherItemSend(String params) {
        voucherItemSendService.voucherItemSend();
        return ReturnT.SUCCESS;
    }



}
